﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HZ.Supervise.Model;

namespace HZ.Supervise.Web.Secondphase.ReportHospital
{
	public partial class HospitalAmountSubsidyDetail : BasePage
	{
		string strSubsidyId = "";
		protected void Page_Load(object sender, EventArgs e)
		{
			
			if (!IsPostBack)
			{
				ViewState["query"] = URLUtil.GetSuperviseQueryFromURL(Request);
				SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
				strSubsidyId =sq.SubsidyID;
				if (!string.IsNullOrEmpty(strSubsidyId)) //如果月份为空 参数有误
				{
					banding();
				}
				else
				{
					Response.Write("<script>history.go(-1);<script>");
				}
				
				//string remark = "";
				//remark = Request.QueryString["id"].ToString();
				//if (remark == "1")
				//{
				//    btnFinish.Visible = true;
					
				//}
				//else 
				//{
				//    btnFinish.Visible = false;
				//}
			}
		}
		//绑定未补助的医院
		private void banding()
		{
			//string strHostpitalid = "";
			//strHostpitalid = Request.QueryString["id2"].ToString();
			string remark = "";
			int totalrecord = 0;
			HZ.Supervise.IBLL.IBLL_Prescription iPrescription = HZ.Supervise.BLLFactory.IBl_Prescription();
			string strwhere = "";
		    strwhere = " and POrderStatus>1";


			if (!strSubsidyId.Trim().Equals(""))//医院名称
			{
				strwhere += " and SubsidyID  = '" + strSubsidyId + "'";
			}
			DataTable dt = iPrescription.GetHospitaleSubsidyDetail(strwhere, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize, out totalrecord);
			AspNetPager1.RecordCount = totalrecord;
			this.gvwDetail.DataSource = dt;
			this.gvwDetail.DataBind();


		}

		protected void AspNetPager1_PageChanged(object sender, EventArgs e)
		{
			banding();
		}

		//protected void btnFinish_Click(object sender, EventArgs e)
		//{

		//}

		protected void gvwDetail_RowCommand(object sender, GridViewCommandEventArgs e)
		{
			if (e.CommandName == "PrescriptionId")
			{
				//设置分组查询字段GroupSelectField
				if (ShowColumns.ShowColumn == null)
				{
					ShowColumns.ShowColumn = new ShowColumns();
					ShowColumns.ShowColumn.GroupFields = GroupFields.PurchaseCountTotal | GroupFields.PriceAvg | GroupFields.PurchaseAmountTotal | GroupFields.DistributeCountTotal | GroupFields.DistributeRate | GroupFields.WareHouseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseRate;
				}
				string url = System.Configuration.ConfigurationManager.AppSettings["HosComDrugs"];
				Response.Redirect(string.Format("{0}", url));
			}

		}
		/// <summary>
		/// 发放补助
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void btnFinish_Click(object sender, EventArgs e)
		{

		}

	}
}
